Skip to content

fix: rename 'commit' column to 'commit_hash' in federation schema#202

Open
y405 wants to merge 1 commit intoSimplyLiz:mainfrom
y405:fix/federation-commit-reserved-keyword
Open

fix: rename 'commit' column to 'commit_hash' in federation schema#202
y405 wants to merge 1 commit intoSimplyLiz:mainfrom
y405:fix/federation-commit-reserved-keyword

Conversation

@y405
Copy link
Copy Markdown

@y405 y405 commented Apr 5, 2026

Summary

ckb federation create fails on all platforms because commit is used as an unquoted column name in the remote_repos table schema. COMMIT is a SQLite reserved keyword, and the modernc.org/sqlite driver enforces this strictly.

Error

Error: failed to create federation: failed to create index: failed to initialize schema:
failed to create schema: SQL logic error: near "commit": syntax error (1)

Fix

Rename the column from commit to commit_hash in all 5 occurrences:

Location Line Change
remote_repos CREATE TABLE 252 commit TEXTcommit_hash TEXT
remote_repos migration 382 commit TEXTcommit_hash TEXT
UpsertRemoteRepo INSERT 670 column list updated
GetRemoteRepos SELECT 681 column list updated
GetAllRemoteRepos SELECT 712 column list updated

The Go struct field CachedRemoteRepo.Commit is unchangedrows.Scan() uses positional binding, not column name mapping, so the field name is decoupled from the SQL column name.

Testing

  • Verified the column rename resolves the schema creation error
  • No other files reference remote_repos.commit directly
  • churn_commits_30d and tx.Commit() (transaction commit) are unaffected — different tokens

Impact

This is a blocking bug — federation is completely unusable without this fix. No workaround exists since schema initialization is the entry point for all federation operations.

Fixes #201

'commit' is a SQLite reserved keyword (COMMIT TRANSACTION).
The modernc.org/sqlite driver enforces this strictly, causing
'ckb federation create' to fail with:

  SQL logic error: near "commit": syntax error (1)

This blocks all federation functionality on affected platforms.

Fix: rename the column to 'commit_hash' in:
- remote_repos table schema (line 252)
- remote_repos migration (line 382)
- UpsertRemoteRepo INSERT (line 670)
- GetRemoteRepos SELECT (line 681)
- GetAllRemoteRepos SELECT (line 712)

The Go struct field 'Commit' is unchanged — Scan() uses
positional binding, not column name mapping.

Fixes SimplyLiz#201
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

federation create fails: SQLite reserved keyword 'commit' used as column name

1 participant